(function($) {
	$(document).ready(function(e) {	
		$("table#da-datatable-jaksa").dataTable({
			"aoColumns": [
				{ "bSortable": false },
				null,
				null,
				null,
				{ "bSortable": false }
			],
			"oLanguage": {
                "sUrl": "plugins/datatables/dataTables.indonesian.txt"
            },
			sPaginationType: "full_numbers"
		});

		$("#da-dialog-add-div").dialog({
			autoOpen: false, 
			title: "Tambah Jaksa", 
			modal: true, 
			width: "640", 
			buttons: [{
					text: "Simpan", 
					click: function() {
						$( this ).find('form#da-dialog-add-val').submit();
					}}]
		}).find('form').validate({
			rules: {
				nip: {
					required: true,
					digits: true
				}, 
				nama: {
					required: true
				}, 
				alamat: {
					required: true
				},
				telp: {
					required: true
				},
				hp: {
					required: true,
					digits: true
				}
			}, 
			invalidHandler: function(form, validator) {
				var errors = validator.numberOfInvalids();
				if (errors) {
					var message = errors == 1
					? 'Ada 1 kolom yang belum diisi'
					: 'Ada ' + errors + ' kolom yang belum diisi';
					$("#da-validate-error").html(message).show();
				} else {
					$("#da-validate-error").hide();
				}
			}
		});

		$("#da-dialog-add").bind("click", function(event) {
			$("#da-dialog-add-div").dialog("option", {modal: true}).dialog("open");
			event.preventDefault();
		});
	});
}) (jQuery);
